package com.example.controller;

import com.example.entity.Customer;
import com.example.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class CustomerController {
    @Value("${server.port}")
    private String serverPort;
    @Autowired
    private CustomerService service;
    @GetMapping("customer/{custId}")
    public Map getCustomerById(@PathVariable("custId") Integer custId){
        Customer customer=service.getById(custId);
        Map<String,Object> result=new HashMap<>();
        result.put("custId",customer.getCustId());
        result.put("custName",customer.getCustName());
        System.out.println(serverPort+"正在查询"+service.getById(custId));
        return result;
    }
}
